﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using StoragePeriod.Data;
using StoragePeriod.Common;
using StoragePeriod.Web.Common;
using StoragePeriod.BLL.StorageForecast;
using StoragePeriod.Model.StorageForecast;

namespace StoragePeriod.Web.SysManage
{
    public partial class QuotaPromptList : SecurityPage
    {
        T_QuotaPrompt tQuotaPrompt = new T_QuotaPrompt();//指标说明操作
        T_RawMaterialType tRawMaterialType = new T_RawMaterialType();//指标表

        public override string PrivCode()
        {
            return "Default";
        }

        //绑定数据
        private void DataBing()
        {
            int QuotaID = Convert.ToInt32(Request.QueryString["QuotaID"].ToString());
            List<E_QuotaPrompt> list = tQuotaPrompt.GetModelList("QuotaID=" + QuotaID);
            this.RepDataList.DataSource = list;
            this.RepDataList.DataBind();
        }

        //获取类型名称
        public string GetTypeName(string TypeID)
        {
            switch (TypeID)
            {
                case "1": return "蔬菜"; break;
                case "2": return "肉制品"; break;
                case "6": return "水产"; break;
                case "7": return "水果"; break;
                default: return "";
            }
        }

        int i = 0;
        public string GetXH()
        {
            i += 1;
            return i.ToString();
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Request.QueryString["QuotaID"] != null)
                {
                    E_RawMaterialType eRawMaterialType = tRawMaterialType.GetModel(int.Parse(Request.QueryString["QuotaID"].ToString()));
                    this.lab_QuotaName.Text = eRawMaterialType.TypeName;
                    DataBing();
                }
            }
        }

        protected void RepDataList_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            int PromptID = Convert.ToInt32(e.CommandArgument);
            tQuotaPrompt.Delete(PromptID);
            DataBing();
            ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "<script>alert('删除成功！');</script>");
        }
    }
}